﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Music.Data;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Music.VariableTemplate
{
    public class VariableTiles : DataTemplateSelector
    {

        public DataTemplate TopTemplate { get; set; }
        public DataTemplate PlaylistTemplate { get; set; }
        public DataTemplate ArtistsBigTemplate { get; set; }
        public DataTemplate ArtistsSmallTemplate { get; set; }
        public DataTemplate GenresLTemplate { get; set; }
        public DataTemplate GenresPTemplate { get; set; }
        public DataTemplate GenresSmallTemplate { get; set; }
        
    
      

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element!=null && item != null)
            {

                if ((item as SampleDataItem).UniqueId.StartsWith("Top"))
                    return TopTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("Playlist"))
                    return PlaylistTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("ArtistsBig"))
                    return ArtistsBigTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("ArtistsSmall"))
                    return ArtistsSmallTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("GenresL"))
                    return GenresLTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("GenresP"))
                    return GenresPTemplate;
                if ((item as SampleDataItem).UniqueId.StartsWith("GenresSmall"))
                    return GenresSmallTemplate;
              }

            return base.SelectTemplateCore(item, container);
        }

    }
}
